import win32com.client

target_path = 'H:\\QL_tool_file\\Window_Tool\\LogicalFile\\SoftwareStarter\\StartEXE.exe'
shortcut_path = 'C:\\Users\\QL_001\\Desktop\\启动器.lnk'

shell = win32com.client.Dispatch("WScript.Shell")
shortcut = shell.CreateShortcut(shortcut_path)
shortcut.IconLocation = 'H:\\QL_tool_file\\Window_Tool\\LogicalFile\\SoftwareStarter\\favicon.ico'
shortcut.TargetPath = target_path
shortcut.Save()

print(f"快捷方式已添加到桌面: {shortcut_path}")





'''
import win32com.client
import os

def create_shortcut(target_path, shortcut_path):
    shell = win32com.client.Dispatch("WScript.Shell")
    shortcut = shell.CreateShortcut(shortcut_path)
    shortcut.TargetPath = target_path
    shortcut.WorkingDirectory = os.path.dirname(target_path)
    shortcut.Save()

# 创建快捷方式
target_path = "C:\\path\\to\\your\\target\\file.exe"
shortcut_path = os.path.join(os.path.expanduser("~"), "Desktop", "Shortcut.lnk")
create_shortcut(target_path, shortcut_path)'''